package com.base.vistter.iframe.inverter.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.base.vistter.iframe.bean.Result;
import com.base.vistter.iframe.entity.SysNoticeUser;
import com.base.vistter.iframe.exception.IframeException;
import com.base.vistter.iframe.service.SysNoticeUserService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@Slf4j
@RequestMapping("/notice/user")
public class SysNoticeUserController {

    @Resource(name = "sysNoticeUserService")
    private SysNoticeUserService sysNoticeUserService;

    @GetMapping()
    public Result<Page<SysNoticeUser>> selectUserNotice(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageNum", defaultValue = "10") Integer pageNum, String title) throws IframeException {
        Page<SysNoticeUser> page = Page.of(pageNo, pageNum);
        return Result.ok(sysNoticeUserService.selectUserNotice(page, title));
    }

    @GetMapping("/{id}")
    public Result<Boolean> updateByNoticeId(@PathVariable("id") Integer id) throws IframeException {
        return Result.ok(sysNoticeUserService.updateByNoticeId(id));
    }

}